home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / TIMEOUT.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  7KB  |  299 lines

  1. /*    SCCS Id: @(#)timeout.c    3.0    89/11/20
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #include    "hack.h"
  6.  
  7. STATIC_DCL void NDECL(stoned_dialogue);
  8. STATIC_DCL void NDECL(vomiting_dialogue);
  9. STATIC_DCL void NDECL(choke_dialogue);
  10. STATIC_DCL void FDECL(hatch_it, (struct obj*));
  11.  
  12. #ifdef OVLB
  13.  
  14. /* He is being petrified - dialogue by inmet!tower */
  15. static const char NEARDATA *stoned_texts[] = {
  16.     "You are slowing down.",        /* 5 */
  17.     "Your limbs are stiffening.",        /* 4 */
  18.     "Your limbs have turned to stone.",    /* 3 */
  19.     "You have turned to stone.",        /* 2 */
  20.     "You are a statue."            /* 1 */
  21. };
  22.  
  23. STATIC_OVL void
  24. stoned_dialogue() {
  25.     register long i = (Stoned & TIMEOUT);
  26.  
  27.     if(i > 0 && i <= SIZE(stoned_texts))
  28.         pline(stoned_texts[SIZE(stoned_texts) - i]);
  29.     if(i == 5)
  30.         Fast &= ~(TIMEOUT|INTRINSIC);
  31.     if(i == 3)
  32.         nomul(-3);
  33. }
  34.  
  35. /* He is getting sicker and sicker prior to vomiting */
  36. static const char NEARDATA *vomiting_texts[] = {
  37.     "You are feeling mildly nauseous.",    /* 11 */
  38.     "You feel slightly confused.",        /* 8 */
  39.     "You can't seem to think straight.",    /* 5 */
  40.     "You feel incredibly sick.",        /* 2 */
  41.     "You suddenly vomit!"            /* 0 */
  42. };
  43.  
  44. STATIC_OVL void
  45. vomiting_dialogue() {
  46.     register long i = (Vomiting & TIMEOUT) / 3L;
  47.  
  48.     if(!((Vomiting & TIMEOUT) % 3L) &&
  49.        i >= 0 && i < SIZE(vomiting_texts))
  50.         pline(vomiting_texts[SIZE(vomiting_texts) - i]);
  51.  
  52.     switch((int)i) {
  53.  
  54.         case 0:    vomit(); morehungry(20); break;
  55.         case 2:    make_confused(HConfusion + d(2,4), FALSE);
  56.         case 3:    make_stunned(HStun + d(2,4), FALSE);
  57.         default:    break;
  58.     }
  59. }
  60.  
  61. static const char NEARDATA *choke_texts[] = {
  62.     "You find it hard to breathe.",
  63.     "You're gasping for air.",
  64.     "You can no longer breathe.",
  65.     "You're turning %s.",
  66.     "You suffocate."
  67. };
  68.  
  69. STATIC_OVL void
  70. choke_dialogue()
  71. {
  72.     register long i = (Strangled & TIMEOUT);
  73.  
  74.     if(i > 0 && i <= SIZE(choke_texts))
  75.         pline(choke_texts[SIZE(choke_texts) - i], Hallucination ?
  76.             hcolor() : blue);
  77. }
  78.  
  79. #endif /* OVLB */
  80. #ifdef OVL0
  81.  
  82. void
  83. timeout()
  84. {
  85.     register struct prop *upp;
  86.     int sleeptime;
  87.  
  88.     if(Stoned) stoned_dialogue();
  89.     if(Vomiting) vomiting_dialogue();
  90.     if(Strangled) choke_dialogue();
  91. #ifdef POLYSELF
  92.     if(u.mtimedone) if(!--u.mtimedone) rehumanize();
  93. #endif
  94.     if(u.ucreamed) u.ucreamed--;
  95.     if(u.uluck && moves % (u.uhave_amulet
  96. #ifdef THEOLOGY
  97.         || u.ugangr
  98. #endif
  99.         ? 300 : 600) == 0) {
  100.     /* Cursed luckstones stop bad luck from timing out; blessed luckstones
  101.      * stop good luck from timing out; normal luckstones stop both;
  102.      * neither is stopped if you don't have a luckstone.
  103.      */
  104.         register int time_luck = stone_luck(FALSE);
  105.         boolean nostone = !carrying(LUCKSTONE);
  106.  
  107.         if(u.uluck > 0 && (nostone || time_luck < 0))
  108.         u.uluck--;
  109.         else if(u.uluck < 0 && (nostone || time_luck > 0))
  110.         u.uluck++;
  111.     }
  112.  
  113.     for(upp = u.uprops; upp < u.uprops+SIZE(u.uprops); upp++)
  114.         if((upp->p_flgs & TIMEOUT) && !(--upp->p_flgs & TIMEOUT)) {
  115.         if(upp->p_tofn) (*upp->p_tofn)();
  116.         else switch(upp - u.uprops){
  117.         case STONED:
  118.             if (!killer) {
  119.                 killer_format = KILLED_BY_AN;
  120.                 killer = "cockatrice";
  121.             } done(STONING);
  122.             break;
  123.         case VOMITING:
  124.             make_vomiting(0L, TRUE);
  125.             break;
  126.         case SICK:
  127.             You("die from your illness.");
  128.             killer_format = KILLED_BY_AN;
  129.             killer = u.usick_cause;
  130.             done(POISONING);
  131.             break;
  132.         case FAST:
  133.             You("feel yourself slowing down.");
  134.             break;
  135.         case CONFUSION:
  136.             HConfusion = 1; /* So make_confused works properly */
  137.             make_confused(0L, TRUE);
  138.             break;
  139.         case STUN:
  140.             HStun = 1;
  141.             make_stunned(0L, TRUE);
  142.             break;
  143.         case BLINDED:
  144.             Blinded = 1;
  145.             make_blinded(0L, TRUE);
  146.             break;
  147.         case INVIS:
  148.             on_scr(u.ux,u.uy);
  149.             if (!Invis && !See_invisible)
  150.                 You("are no longer invisible.");
  151.             break;
  152.         case WOUNDED_LEGS:
  153.             heal_legs();
  154.             break;
  155.         case HALLUC:
  156.             Hallucination = 1;
  157.             make_hallucinated(0L, TRUE);
  158.             break;
  159.         case SLEEPING:
  160.             if (unconscious() || Sleep_resistance)
  161.                 Sleeping += rnd(100);
  162.             else {
  163.                 You("fall asleep.");
  164.                 sleeptime = rnd(20);
  165.                 nomul(-sleeptime);
  166.                 nomovemsg = "You wake up.";
  167.                 Sleeping = sleeptime + rnd(100);
  168.             }
  169.             break;
  170.         case STRANGLED:
  171.             killer_format = KILLED_BY;
  172.             killer = "strangulation";
  173.             done(DIED);
  174.             break;
  175.         case FUMBLING:
  176.             /* call this only when a move took place.  */
  177.             /* otherwise handle fumbling msgs locally. */
  178.             if (!Levitation && u.umoved) {
  179.                 if (OBJ_AT(u.ux, u.uy))
  180.                 You("trip over something.");
  181.                 else
  182.                 switch (rn2(4)) {
  183.                     case 1:
  184.                     if (ACCESSIBLE(levl[u.ux][u.uy].typ)) { /* not POOL or STONE */
  185.                         if (Hallucination) pline("A rock bites your foot.");
  186.                         else You("trip over a rock.");
  187.                         break;
  188.                     }
  189.                     case 2:
  190.                     if (Hallucination) You("slip on a banana peel.");
  191.                     else You("slip and nearly fall.");
  192.                     break;
  193.                     case 3:
  194.                     You("flounder.");
  195.                     break;
  196.                     default:
  197.                     You("stumble.");
  198.                 }
  199.                 nomul(-2);
  200.                 nomovemsg = "";
  201.             }
  202.             Fumbling = rnd(20);
  203.             break;
  204.         }
  205.     }
  206. }
  207.  
  208. #endif /* OVL0 */
  209. #ifdef OVLB
  210.  
  211. STATIC_OVL void
  212. hatch_it(otmp)        /* hatch the egg "otmp" if possible */
  213. register struct obj *otmp;
  214. {
  215.     register struct monst *mtmp;
  216. #ifdef POLYSELF
  217.     int yours = otmp->spe;
  218. #endif
  219.  
  220.     if(monstermoves-otmp->age > 200)  /* very old egg - it's dead */
  221.         otmp->corpsenm = -1;
  222. #ifdef LINT    /* long conv. ok */
  223.     else if(rnd(150) > 150) {
  224. #else
  225.     else if(rnd((int)(monstermoves-otmp->age)) > 150) {
  226. #endif
  227.         mtmp = makemon(&mons[big_to_little(otmp->corpsenm)], u.ux, u.uy);
  228.         useup(otmp);
  229.         if(mtmp) {
  230.  
  231.         if(Blind)
  232.             You("feel something %s from your pack!",
  233.             locomotion(mtmp->data, "drop"));
  234.         else
  235.             You("see %s %s out of your pack!",
  236.             an(mtmp->data->mname),
  237.             locomotion(mtmp->data, "drop"));
  238.  
  239. #ifdef POLYSELF
  240.         if (yours) {
  241.             struct monst *mtmp2;
  242.  
  243.             pline("Its cries sound like \"%s.\"",
  244.             flags.female ? "mommy" : "daddy");
  245.             if (mtmp2 = tamedog(mtmp, (struct obj *)0))
  246.             mtmp = mtmp2;
  247.             mtmp->mtame = 20;
  248.             while(otmp = (mtmp->minvent)) {
  249.             mtmp->minvent = otmp->nobj;
  250.             free((genericptr_t)otmp);
  251.             }
  252.             return;
  253.         }
  254. #endif
  255.         if(mtmp->data->mlet == S_DRAGON) {
  256.             struct monst *mtmp2;
  257.  
  258.             verbalize("Gleep!");        /* Mything eggs :-) */
  259.             if (mtmp2 = tamedog(mtmp, (struct obj *)0))
  260.             mtmp = mtmp2;
  261.             while(otmp = (mtmp->minvent)) {
  262.             mtmp->minvent = otmp->nobj;
  263.             free((genericptr_t)otmp);
  264.             }
  265.         }
  266.         }
  267.     }
  268. }
  269.  
  270. #endif /* OVLB */
  271. #ifdef OVL1
  272.  
  273. void
  274. hatch_eggs()        /* hatch any eggs that have been too long in pack */
  275. {
  276.     register struct obj *otmp,/* *ctmp, /* use of ctmp commented out below*/
  277.         *otmp2;
  278.  
  279.     for(otmp = invent; otmp; otmp = otmp2) {
  280.  
  281.         otmp2 = otmp->nobj;        /* otmp may hatch */
  282.         if(otmp->otyp == EGG && otmp->corpsenm >= 0) hatch_it(otmp);
  283.     }
  284.  
  285. /*    Not yet - there's a slight problem with "useup" on contained objs.
  286.     for(otmp = fcobj; otmp; otmp = otmp2) {
  287.  
  288.         otmp2 = otmp->nobj;
  289.         for(ctmp = invent; ctmp; ctmp = ctmp->nobj)
  290.         if(otmp->cobj == ctmp)
  291.             if(ctmp->otyp != ICE_BOX)
  292.             if(otmp->otyp == EGG && otmp->corpsenm >= 0)
  293.                 hatch_it(otmp);
  294.     }
  295. */
  296. }
  297.  
  298. #endif /* OVL1 */
  299.